import csv
from sklearn.neighbors import NearestNeighbors
import numpy as np

class CSVFile:
	csvfile=''
	def open(self, filename, delimitador):
		self.csvfile = csv.reader(open(filename), delimiter = delimitador)
	
	def values(self):
		valores=[]
		for i in self.csvfile:
			valores.append( [ float(i[0]), float(i[1]) ] )
		return valores

class vizinho_proximo:

	def __init__(self, matriz):
		calc = NearestNeighbors(n_neighbors=2, algorithm='ball_tree').fit(matriz)
		distancias, indices = calc.kneighbors(matriz)
		print "Indices: %s" % indices
		print "Distancias %s" % distancias

print "Digite o local do arquivo:"
local  = raw_input()

arquivo = CSVFile()
arquivo.open(local, ',')
valoresXY = arquivo.values()

vmp = vizinho_proximo(valoresXY)
